package jp.sourceforge.akjrcp.youtubedl;

import org.eclipse.swt.widgets.Composite;

import jp.sourceforge.akjrcp.ui.CComboFieldEditor;
import jp.sourceforge.akjrcp.util.YoutubeDLUtils;

public class YoutubeDLFmtFieldEditor extends CComboFieldEditor{

	public YoutubeDLFmtFieldEditor(String hq_settings, String string,int width, Composite fieldEditorParent) {
		super(hq_settings,string,width,fieldEditorParent);
	}

	public YoutubeDLFmtFieldEditor(String hq_settings, String string, Composite fieldEditorParent) {
		super(hq_settings,string,fieldEditorParent);
	}

	public void addValues() {
		for (int i = 0; i < YoutubeDLUtils.fmts.length; i++) {
			getCComboControl().add(YoutubeDLUtils.fmts[i]);
		}
		
	}
	
	public static int parseFormat(String label){
		int ret=0;
		int s=label.indexOf("(");
		if(s!=-1){
			int e=label.indexOf(")",s+1);
			if(e!=-1){
				String num=label.substring(s+1,e);
				try{
					ret=Integer.parseInt(num);
					return ret;
				}catch(Exception ex){
					return ret;
				}
			}
		}
		ret=Integer.parseInt(label);
		return ret;
	}

}
